#include <stdio.h>
#include <ctype.h>

#define MAX_SIZE 10

const int segments[10][7] = {{1, 1, 1, 1, 1, 1},
                             {0, 1, 1},
                             {1, 1, 0, 1, 1, 0, 1},
                             {1, 1, 1, 1, 0, 0, 1},
                             {0, 1, 1, 0, 0, 1, 1},
                             {1, 0, 1, 1, 0, 1, 1},
                             {1, 0, 1, 1, 1, 1, 1},
                             {1, 1, 1},
                             {1, 1, 1, 1, 1, 1, 1},
                             {1, 1, 1, 1, 0, 1, 1}};
int text[3][MAX_SIZE * 4] = {0};

void process_digit(int digit, int position);
void print_digits_array(int);

int main()
{
    int index = 0, vec_print[MAX_SIZE] = {0};
    char c;
    printf("Please input numbers: ");
    while ((c = getchar()) != '\n' && index < MAX_SIZE) {
        if (isdigit(c)) {
            vec_print[index++] = c - '0';
        }
    }
    
    for (int i = 0; i < MAX_SIZE; i++)
        process_digit(vec_print[i], i);

    print_digits_array(index);

    return 0;
}

void process_digit(int digit, int position)
{
    int temp[7] = {0}, col_index = 4 * position;
    for (int i = 0; i < 7; i++)
        temp[i] = segments[digit][i];

    text[0][col_index + 1] = temp[0];
    text[1][col_index + 2] = temp[1];
    text[2][col_index + 2] = temp[2];
    text[2][col_index + 1] = temp[3];
    text[2][col_index] = temp[4];
    text[1][col_index] = temp[5];
    text[1][col_index + 1] = temp[6];
}

void print_digits_array(int len)
{
    for (int i = 0; i < 3; i++)
    {
        switch (i) {
            case 0:         //First Line
                for (int j = 0; j < 4 * len; j++){
                    if (text[i][j])
                        printf("_");
                    else
                        printf(" ");
                }
                printf("\n");
                break;
            case 1: case 2: //Second Line
                for (int j = 0; j < 4 * len; j++) {
                    if (text[i][j] && (j % 4 == 0 || j % 4 == 2))
                        printf("|");
                    if (text[i][j] && (j % 4 == 1))
                        printf("_");
                    if (!text[i][j])
                        printf(" ");
                }
                printf("\n");
                break;
        }
    }
    printf("\n");
}
